<?php

/**
 * This is the model class for table "c_quota_header".
 *
 * The followings are the available columns in table 'c_quota_header':
 * @property integer $id
 * @property string $quota_date
 * @property string $job_date
 * @property string $summary
 * @property string $amount
 * @property integer $inv_id
 * @property string $inv_num
 * @property string $customer
 * @property string $product
 * @property string $contact
 * @property string $issue_on
 * @property string $create_date
 * @property string $update_date
 * @property string $update_user
 */
class Quotation extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'c_quota_header';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('quota_date, job_date, summary, amount, customer, product, contact, issue_on, create_date, update_date, update_user', 'required'),
			array('inv_id', 'numerical', 'integerOnly'=>true),
			array('inv_num', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, quota_date, job_date, summary, amount, inv_id, inv_num, customer, product, contact, issue_on, create_date, update_date, update_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'quota_date' => 'Quota Date',
			'job_date' => 'Job Date',
			'summary' => 'Summary',
			'amount' => 'Amount',
			'inv_id' => 'Inv',
			'inv_num' => 'Inv Num',
			'customer' => 'Customer',
			'product' => 'Product',
			'contact' => 'Contact',
			'issue_on' => 'Issue On',
			'create_date' => 'Create Date',
			'update_date' => 'Update Date',
			'update_user' => 'Update User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('quota_date',$this->quota_date,true);
		$criteria->compare('job_date',$this->job_date,true);
		$criteria->compare('summary',$this->summary,true);
		$criteria->compare('amount',$this->amount,true);
		$criteria->compare('inv_id',$this->inv_id);
		$criteria->compare('inv_num',$this->inv_num,true);
		$criteria->compare('customer',$this->customer,true);
		$criteria->compare('product',$this->product,true);
		$criteria->compare('contact',$this->contact,true);
		$criteria->compare('issue_on',$this->issue_on,true);
		$criteria->compare('create_date',$this->create_date,true);
		$criteria->compare('update_date',$this->update_date,true);
		$criteria->compare('update_user',$this->update_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Quotation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
